﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wedo.Utility.Common
{
    /// <summary>
    /// List 分组实现
    /// </summary>
    /// <typeparam name="Tkey"></typeparam>
    /// <typeparam name="TElement"></typeparam>
    public class CommonGroup<Tkey, TElement> :List<TElement> , IGrouping<Tkey, TElement>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key">关键字</param>
        public CommonGroup(Tkey key)
        {
            _Key = key;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="initData"></param>
        public CommonGroup(Tkey key,IEnumerable<TElement> initData)
        {
            _Key = key;
            initData = initData ?? new List<TElement>();
            this.AddRange(initData);
        }

        private Tkey _Key;
        public Tkey Key
        {
            get {
                return _Key;
            }
        }
    }
}
